package com.openlab.callsystem.utils;

import com.openlab.callsystem.enums.BusinessType;
import com.openlab.callsystem.enums.WindowStatus;
import com.openlab.callsystem.mapper.LogMapper;
import com.openlab.callsystem.service.LogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.CopyOnWriteArraySet;
import java.util.concurrent.atomic.AtomicInteger;
@Configuration
public class QueueBeans {
    @Autowired
    LogService logService;
    @Bean
    public  ConcurrentHashMap<Integer, WindowStatus> getCommonWindows() {
        ConcurrentHashMap<Integer, WindowStatus>  commonWindows=new ConcurrentHashMap<>();
        return commonWindows;
    }
    @Bean
    public ConcurrentHashMap<Integer, WindowStatus> getVipWindows() {
        ConcurrentHashMap<Integer,WindowStatus> vipWindows=new ConcurrentHashMap<>();
        return vipWindows;
    }
    //正在办理中的普通业务;
    @Bean
    public AtomicInteger getCommonNumber() {
        AtomicInteger commonNumber=new AtomicInteger(logService.calCount(BusinessType.Common.getValue()));
        return commonNumber;
    }
    @Bean
    public  AtomicInteger getVipNumber() {
        AtomicInteger vipNumber=new AtomicInteger(logService.calCount(BusinessType.Vip.getValue()));
        return vipNumber;
    }
    @Bean
    public AtomicInteger getCommonCurrent() {
        AtomicInteger commonCurrent=new AtomicInteger(-1);
        return commonCurrent;
    }
    @Bean
    public AtomicInteger getVipCurrent() {
        AtomicInteger vipCurrent=new AtomicInteger();
        return vipCurrent;
    }
    @Bean
    public  ConcurrentLinkedQueue<Integer> getVipQueues() {
        ConcurrentLinkedQueue vipQueues=new ConcurrentLinkedQueue<>();
        return vipQueues;
    }
    @Bean
    public  ConcurrentLinkedQueue<Integer> WindowsQueues() {
        ConcurrentLinkedQueue vipQueues=new ConcurrentLinkedQueue<>();
        return vipQueues;
    }
    @Bean
    public  ConcurrentLinkedQueue<Integer> getCommonQueues() {
        ConcurrentLinkedQueue commonQueues=new ConcurrentLinkedQueue<>();
        return commonQueues;
    }
    @Bean
    public  CopyOnWriteArraySet<Integer> getVipWork() {
        CopyOnWriteArraySet vipWork=new CopyOnWriteArraySet<>();
        return vipWork;
    }
    @Bean
    public CopyOnWriteArraySet<Integer> getCommonWork() {
        CopyOnWriteArraySet commonWork=new CopyOnWriteArraySet<>();
        return commonWork;
    }
}
